//
//  WechatViewController.m
//  AntsExpress
//
//  Created by slccper on 16/1/12.
//  Copyright © 2016年 slccper. All rights reserved.
//

#import "WechatViewController.h"
#import <WebKit/WebKit.h>
@interface WechatViewController ()<WKNavigationDelegate,WKUIDelegate>
@property (retain, nonatomic)  WKWebView *WebView;
@end

@implementation WechatViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
    configuration.userContentController = [WKUserContentController new];
    
    WKPreferences *preferences = [WKPreferences new];
    preferences.javaScriptCanOpenWindowsAutomatically = YES;
    preferences.minimumFontSize = 30.0;
    configuration.preferences = preferences;
    
    self.WebView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:configuration];
    self.title=@"客服微信";
    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"WeChat" ofType:@"html"];
    NSString *htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    _WebView.navigationDelegate = self;
    _WebView.UIDelegate = self;
    [_WebView loadHTMLString:htmlString baseURL:nil];
    _WebView.autoresizingMask=UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - WKNavigationDelegate
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
    NSLog(@"%@",webView.URL);
    decisionHandler(WKNavigationActionPolicyAllow);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
